//
//  RunCell.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/8/25.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "RunCell.h"
#import "DataTool.h"
@interface RunCell()
@property (weak, nonatomic) IBOutlet UIImageView *run;
@property (weak, nonatomic) IBOutlet UILabel *date;
@property (weak, nonatomic) IBOutlet UILabel *distance;
@property (weak, nonatomic) IBOutlet UILabel *time;

@property (weak, nonatomic) IBOutlet UIImageView *nexty;
@property (weak, nonatomic) IBOutlet UILabel *cal;
@end
@implementation RunCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}
//创建自定义可重用的cell对象
+ (instancetype)setRunCellWithTableView:(UITableView *)tableView
{
    static NSString *reuseId = @"RunCell";
    RunCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
    if (cell == nil){
        cell = [[[NSBundle mainBundle] loadNibNamed:@"RunCell" owner:nil options:nil] lastObject];
    }
    return cell;
}

-(void)setInfo:(RunRecordInfo *)info{
    //设置控件的值
    _info =info;
    _date.text=[DataTool timestampChaStringDate2:[info.create_at longLongValue]];
    _time.text=[DataTool tampChangeToHour:[info.time intValue]];
   int distance = [info.distance intValue]/1000;
   NSString *d =[NSString stringWithFormat:@"%i",distance];
    _distance.text = [d stringByAppendingString:@"km"];
}

-(void)setSteps:(WalkSteps *)steps{
    _nexty.hidden=YES;
    _cal.hidden=NO;
    _steps =steps;
    _date.text=[DataTool timestampChaStringDate2:[_steps.create_at longLongValue]];
    ;
    _distance.text=[_steps.step stringByAppendingString:@" 步"];
    _time.text=[_steps.distance stringByAppendingString:@" 米"];
    //现实转换
    _cal.text = [NSString stringWithFormat:@"%.2f,%@",[_steps.distance floatValue]/1000,@" 千卡"];
}
@end
